#include "Field.h"
#include <math.h>
#include <stdlib.h>

Field::Field()
{

}

Field::~Field()
{

}

void Field::SetValue(char *cValue)
{
	m_cValue = cValue;
}

void Field::SetType( ESQLType eType )
{
	m_eType = eType;
}

void Field::SetName( std::string sName )
{
	m_sName = sName;
}

const char* Field::GetString()
{
	return m_cValue;
}

float Field::GetFloat()
{
	return m_cValue ? static_cast< float >( atof( m_cValue ) ) : 0.0f;
}

double Field::GetDouble()
{
	return m_cValue ? atof( m_cValue ) : 0.0;
}

bool Field::GetBool()
{
	return m_cValue ? atoi( m_cValue ) != 0 : false;
}

unsigned char Field::GetUInt8()
{
	return m_cValue ? static_cast< unsigned char >( atoi( m_cValue ) ) : 0;
}

char Field::GetInt8()
{
	return m_cValue ? static_cast< char >( atoi( m_cValue ) ) : 0;
}

unsigned short Field::GetUInt16()
{
	return m_cValue ? static_cast< unsigned short >( atoi( m_cValue ) ) : 0;
}

short Field::GetInt16()
{
	return m_cValue ? static_cast< short >( atoi( m_cValue ) ) : 0;
}

unsigned int Field::GetUInt32()
{
	return m_cValue ? static_cast< unsigned int >( atoi( m_cValue ) ) : 0;
}

int Field::GetInt32()
{
	return m_cValue ? atoi( m_cValue ) : 0;
}

long Field::GetInt64()
{
	return m_cValue ? atol( m_cValue ) : 0;
}

unsigned long Field::GetUInt64()
{
	return m_cValue ? static_cast< unsigned long >( atol( m_cValue ) ) : 0;
}
